package 第三轮工作.北京印刷学院;

import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

import java.io.IOException;

public class BJYsU {
    public static void main(String[] args) throws IOException {
        int i = 0;
        String Url = "https://jdgc.bigc.edu.cn/szdw/zrjs/index.htm";
        Connection connect = Jsoup.connect(Url);
        Document post = connect.post();
        for (Element elementsByClass : post.getElementsByTag("tbody")) {
            for (Element element : elementsByClass.getElementsByTag("p")) {
//                System.out.println(element.text());
                for (Element a : element.getElementsByTag("a")) {
                    String attr = a.attr("href");
//                    System.out.println(attr);
//                    System.out.println(a.text());

                    Connection connect1 = Jsoup.connect(attr);

                    try {
                        Document post1 = connect1.post();
                        for (Element p : post1.getElementsByTag("p")) {
                            System.out.println(p.text());
//                            i++;
//                            if (i > 30) {
//                                break;
//                            }
                        }
                    } catch (Exception e) {
                        System.out.println("访问超时");
                    }

                }

            }
        }
    }
}
